package com.yy.hi.ui.refresh;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public abstract class HiOverView extends FrameLayout {

    public enum HiRefreshState {
        STATE_INIT,
        STATE_VISIBLE,
        STATE_REFRESH,//达到了下拉刷新的高度
        STATE_OVER,//超出可刷新距离
        STATE_OVER_RELEASE;
    }

    protected HiRefreshState mRefreshState = HiRefreshState.STATE_INIT;
    public int mPullRefreshHeight;
    public float minDamp = 1.6f;
    public float maxDamp = 2.2f;

    public HiOverView(@NonNull Context context) {
        super(context);
    }

    public HiOverView(@NonNull Context context,
                      @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public HiOverView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public void setRefreshState(HiRefreshState refreshState) {
        mRefreshState = refreshState;
    }

    public HiRefreshState getRefreshState() {
        return mRefreshState;
    }

    public abstract void init();

    protected abstract void onScroll(int scrollY, int mPullRefreshHeight);

    /**
     * 显示Overlay
     */
    protected abstract void onVisible();

    /**
     * 超过视图高度
     */

    public abstract void onOver();

    /**
     * 开始刷新
     */
    public abstract void onRefresh();

    /**
     * 刷新完成
     */
    public abstract void onFinish();

}
